const __COMPONENT_NAME__ = Symbol.for("node");
function broadcast(eventName, params) {
  this.$children.forEach((child) => {
    let name = child.$options.__component_name__;

    if (name === __COMPONENT_NAME__) {
      child.$emit.apply(child, [eventName].concat(params));
    } else {
      broadcast.apply(child, [eventName].concat([params]));
    }
  });
}
export default {
  __component_name__: __COMPONENT_NAME__,
  inject: ["getManager"],
  props: {
    id: {
      type: String,
      required: true,
    },
    pid: String,
    data: {
      type: [Object, Array],
      required: true,
    },
  },
  data() {
    return {
      // actived: false,
      // isLast: false,
      // isFirst: false,
      // actived: false,
    };
  },
  computed: {
    // dots() {
    //   let res = [];
    //   if (!this.isFirst) {
    //     res.push({ type: "left" });
    //   }
    //   if (!this.isLast) {
    //     res.push({ type: "right" });
    //   }
    //   return res;
    // },
  },
  mounted() {
    // console.log("mounted", this.id);
    this.getManager()?.addViewNode(this);
  },
  // beforeUnmount() {
  //   console.log("unmounted", this.id);
  //   this.getManager()?.removeViewNode(this);
  // },
  beforeDestroy() {
    // console.log("beforedestory", this.id);
    this.getManager()?.removeViewNode(this);
  },

  methods: {
    // dispatch(componentName, eventName, params) {
    //   var parent = this.$parent || this.$root;
    //   var name = parent.$options.componentName;
    //
    //   while (parent && (!name || name !== componentName)) {
    //     parent = parent.$parent;
    //
    //     if (parent) {
    //       name = parent.$options.componentName;
    //     }
    //   }
    //   if (parent) {
    //     parent.$emit.apply(parent, [eventName].concat(params));
    //   }
    // },
    // broadcast(eventName, params) {
    //   broadcast.call(this, eventName, params);
    // },
  },
};
